/*
 * @Author: szx
 * @Date: 2021-11-11 14:03:49
 * @LastEditTime: 2021-11-11 14:17:43
 * @Description:
 * @FilePath: \leetcode\1-99\11\11.cpp
 */
#include <iostream>
#include <vector>
using namespace std;
class Solution {
   public:
    int maxArea(vector<int>& height) {
        int i = 0, j = height.size() - 1;
        int res = 0;
        int sum = 0;
        while (i < j) {
            sum = (j - i) * min(height[i], height[j]);
            if (sum > res) res = sum;
            if (height[i] < height[j]) {
                i++;
            } else {
                j--;
            }
        }
        return res;
    }
};
